# coding=utf-8

# try:
# a = b
# 	b = c
# except Exception, e:
# 	print(e)

# 	try:
# 		aa
# 	except Exception, e2:
# 		print(e2)
# finally:
# 	print("finally ok")
# #try except finally 可以连用
# #try except 可以嵌套使用

# try:
# 	# str1
# 	assert 1 == 2
# except Exception, e:
# 	print('assert 1 == 2')


# try:
# 	# str1
# 	raise IndexError
# except Exception, e:
# 	print('raise IndexError')

# import traceback

# try:
# 	str2
# except Exception, e:
# 	# Traceback (most recent call last):
# 	#   File "/Users/zhuxuehuang/git.oschina.net/pystudy1503/try1.py", line 34, in <module>
# 	#     str2
# 	# NameError: name 'str2' is not defined
# 	print('=' * 20)
# 	print(e)
# 	print(traceback.print_exc())

# import sys

# try:
# 	str3
# except:
# 	info = sys.exc_info()
# 	print(info)


import sys


def division(a=1, b=1):
    if b == 0:
        print 'b eq 0'
        sys.exit(1)
    else:
        return a / b

# division(1, 0)



import traceback

a = 10
b = 0

try:
    print division(a, b)
except:
    print 'invoking division failed.'
    traceback.print_exc()
    sys.exit(1)

